package jukebox.model.qnacomment;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class QnACommentDAOImpl implements QnACommentDAO {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;
	@Override
	public void writeComment(QnACommentVO qcvo) {
		sqlSessionTemplate.insert("qnaboard.writeComment", qcvo);
	}

	@Override
	public void updateComment(QnACommentVO qcvo) {
		sqlSessionTemplate.insert("qnaboard.updateComment", qcvo);
	}

	@Override
	public void deleteComment(int no) {
		sqlSessionTemplate.insert("qnaboard.deleteComment", no);

	}

	@Override
	public void choiceComment(int commentNo) {
		sqlSessionTemplate.update("qnaboard.choiceComment", commentNo);
	}

	@Override
	public List<QnACommentVO> findCommentListByBoardNo(int no) {
		return sqlSessionTemplate.selectList("qnaboard.findCommentListByBoardNo", no);
	}
	
	@Override
	public List<QnACommentVO> findPagedCommentListByBoardNo(Map<String, Integer> map) {
		return sqlSessionTemplate.selectList("qnaboard.findPagedCommentListByBoardNo", map);
	}
	
	@Override
	public int hasBeenChoiced(int no) {
		return sqlSessionTemplate.selectOne("qnaboard.hasBeenChoiced", no);
	}

	@Override
	public int getCountComment(int boardNo) {
		return sqlSessionTemplate.selectOne("qnaboard.getCountComment", boardNo);
	}
	
	

}
